package com.cn.zpark;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: User
 * @Description:
 * @author: RZS
 * @date: 2022/4/27  10:38
 */
public class User {
    private String name;
    private Integer age;

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) throws Exception {
        // 判断年龄是否合法
        if(age >= 140 || age <= 0){
            System.err.println("年龄不合法");
            throw new Exception("年龄不合法");
        }
        this.age = age;
    }
}
